package com.cxc.simple;

public class MyThreadTest {

    public static void main(String[] args) {
        Runnable r = new MyThread();
        Thread t1 = new Thread(r);
        Thread t2 = new Thread(r);
        t1.start();
        t2.start();
    }

}


class  MyThread  implements Runnable{

    int a;
    @Override
    public void run() {
        a=0;
        while (true){
            System.out.println("result:===>"+ a++);
            try{
                Thread.sleep((long)(Math.random() * 1000));
            }catch (InterruptedException e){
                e.printStackTrace();
            }

            if (a==30){
                break;
            }
        }
    }
}
